package com.ruoyi.web.controller.ltd_web;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.ltd_web.domain.LtdHistory;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ltd_web.domain.LtdOperation;
import com.ruoyi.ltd_web.service.ILtdOperationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公司近期活动信息Controller
 *
 * @author ruoyi
 * @date 2024-12-17
 */
@RestController
@RequestMapping("/system/operation")
public class LtdOperationController extends BaseController
{
    @Autowired
    private ILtdOperationService ltdOperationService;

    /**
     * 查询公司近期活动信息列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(LtdOperation ltdOperation)
    {
        startPage();
        List<LtdOperation> list = ltdOperationService.selectLtdOperationList(ltdOperation);
        return getDataTable(list);
    }

    /**
     * 导出公司近期活动信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:operation:export')")
    @Log(title = "公司近期活动信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LtdOperation ltdOperation)
    {
        List<LtdOperation> list = ltdOperationService.selectLtdOperationList(ltdOperation);
        ExcelUtil<LtdOperation> util = new ExcelUtil<LtdOperation>(LtdOperation.class);
        util.exportExcel(response, list, "公司近期活动信息数据");
    }

    /**
     * 获取公司近期活动信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:operation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ltdOperationService.selectLtdOperationById(id));
    }

    /**
     * 新增公司近期活动信息
     */
    @PreAuthorize("@ss.hasPermi('system:operation:add')")
    @Log(title = "公司近期活动信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LtdOperation ltdOperation)
    {
        return toAjax(ltdOperationService.insertLtdOperation(ltdOperation));
    }

    /**
     * 修改公司近期活动信息
     */
    @PreAuthorize("@ss.hasPermi('system:operation:edit')")
    @Log(title = "公司近期活动信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LtdOperation ltdOperation)
    {
        return toAjax(ltdOperationService.updateLtdOperation(ltdOperation));
    }

    /**
     * 删除公司近期活动信息
     */
    @PreAuthorize("@ss.hasPermi('system:operation:remove')")
    @Log(title = "公司近期活动信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ltdOperationService.deleteLtdOperationByIds(ids));
    }

    /**
     * 近期活动删除--状态修改
     */
    @PreAuthorize("@ss.hasPermi('system:operation:edit')")
    @Log(title = "近期活动删除--状态修改", businessType = BusinessType.UPDATE)
    @PutMapping("/changeStatus")
    public AjaxResult changeStatus(@RequestBody LtdOperation ltdOperation)
    {
        return toAjax(ltdOperationService.updateLtdOperation(ltdOperation));
    }
}
